<div style="width: 100%">
<!--    产线主管、辅助主管 动态产生表-->
    <div id="bzcjCxZhuGuanTableDiv" style="width: 100%">
        <button  style=" width:100%;text-align: left" class="layui-btn"><span style="font-size: 18px">产线主管、辅助主管综合绩效计算表</span></button>

    </div>
    <!--    总计划主管-->
    <div id="bzcjTotalZhuGuanTableDiv" style="width: 100%">
<!--        <button  style=" width:100%;text-align: left" class="layui-btn"><span style="font-size: 18px">总计划主管综合绩效计算表</span><span style="color: #86b9e0">（所有产线主管的平均值+规范化奖金）*出勤率+发现异常奖金-违规扣款</span><span style="color:red"></span></button>-->
        <button  style=" width:100%;text-align: left" class="layui-btn"><span style="font-size: 18px">总计划主管综合绩效计算表</span></button>
        <table id="bzcjTotalZhuGuanTable"></table>
        <div id="bzcjTotalZhuGuanTableToolbar" style="display: none;">
            <div style="width: 350px;">
                <a class="easyui-linkbutton c1" style="height: 90%" data-options="plain:true" onclick="javaScript:$('#bzcjTotalZhuGuanTable').edatagrid('saveRow')"><i class="fa fa-floppy-o fa-fw" aria-hidden="true"></i>保存</a>
                <a class="easyui-linkbutton" data-options="plain:true">|</a>
<!--                <a class="easyui-linkbutton c6" style="height: 90%" data-options="plain:true" onclick="javaScript:$('#bzcjTotalZhuGuanTable').edatagrid('addRow')"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>新增</a>-->
<!--                <a class="easyui-linkbutton" data-options="plain:true">|</a>-->
<!--                <a class="easyui-linkbutton c5" style="height: 90%" data-options="plain:true" onclick="javaScript:$('#bzcjTotalZhuGuanTable').edatagrid('destroyRow')"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>删除</a>-->
<!--                <a class="easyui-linkbutton" data-options="plain:true">|</a>-->
                <a class="easyui-linkbutton c4" style="height: 90%" data-options="plain:true" onClick="loadBzcjTotalZhuGuanTableData()"><i class="fa fa-repeat fa-fw" aria-hidden="true"></i>刷新</a>
            </div>
        </div>
    </div>
   <script>
       //【产线主管】、【辅助主管】修改操作：赋值绩效奖金标准：value1~获取value12的字段相加统计 赋值绩效奖金标准中
       function bzCxZhuGuanPerformanceBonus (){
           var postName = getEditBzcjZhuGuan("postName").val();
           var performanceBonus = getEditBzcjZhuGuan("performanceBonus");
           var sumPerformanceBonus=0;
           //获取value1~获取value12的字段并进行相加赋值到绩效奖金标准中
           let j=0; //记录人数
           for (let i=1;i<=12;i++){
             var z=  getEditBzcjZhuGuan("value"+i)
               //判断是否有值，若Undefined证明就没有值
             if (z){
             var v=z.textbox("getValue");
             v=Number(v)
             if (!isNaN(v))
                 sumPerformanceBonus+=v;
                 j++;
             }
           }
           //赋值绩效奖金标准:每个组长的平均数
           if (sumPerformanceBonus){
               if (postName.indexOf("辅助")!=-1){
                   sumPerformanceBonus=fomatFloat(sumPerformanceBonus/j*1.2,2);
               }else {
                   sumPerformanceBonus=fomatFloat(sumPerformanceBonus/j,2);
               }

           }
           performanceBonus.textbox("setValue",sumPerformanceBonus);
       }

       //规范化奖金
       function bzZhuGuanPenalty5s() {
           var penalty5s = getEditBzcjZhuGuan("penalty5s");
           //绩效奖金标准
           var performanceBonus = getEditBzcjZhuGuan("performanceBonus").textbox("getValue");
           performanceBonus=performanceBonus?Number(performanceBonus):0;
           var score5s = getEditBzcjZhuGuan("score5s").textbox("getValue");
           score5s=score5s?Number(score5s):0;
           var result=0;
           if (score5s>=85){
               result=performanceBonus*0.05
           }
           result=fomatFloat(result,2)
           penalty5s.textbox("setValue",result)
       }

       //赋值最终绩效奖金
       function totalBaoZhuangZhuGuan() {
           console.log("赋值最终绩效奖金")
           //绩效奖金标准
           var performanceBonus = getEditBzcjZhuGuan("performanceBonus").textbox("getValue");
           performanceBonus=performanceBonus?Number(performanceBonus):0;
           var attendanceRate = getEditBzcjZhuGuan("attendanceRate").textbox("getValue");
           attendanceRate=attendanceRate?performanceBonus*Number(attendanceRate/100):performanceBonus;
           //发现异常奖金
           var exceptionBonus = getEditBzcjZhuGuan("exceptionBonus").textbox("getValue");
           exceptionBonus=exceptionBonus?Number(exceptionBonus):0;
           //违规扣款
           var illegalFine = getEditBzcjZhuGuan("illegalFine").textbox("getValue");
           illegalFine=illegalFine?Number(illegalFine):0;
           //规范化奖金
           var penalty5s = getEditBzcjZhuGuan("penalty5s");
           if (penalty5s){
               penalty5s=penalty5s.textbox("getValue");
           }
           penalty5s=penalty5s?Number(penalty5s):0;
           //综合<br/>绩效（元）
           var resultMoney = getEditBzcjZhuGuan("resultMoney");

           var result="";
           //辅助主管还需要乘以0.95
           var postName = getEditBzcjZhuGuan("postName").val();
           result=fomatFloat(attendanceRate+exceptionBonus+penalty5s-illegalFine,2);
           if (postName.indexOf("辅助")!=-1){
               result=fomatFloat(result*0.95,2);
           }
           resultMoney.textbox("setValue",result);
       }

        //全部主管总计金额
       function totalBzSumMoney() {
           let resultSumMoney=0;
           //获取辅助主管和产线主管之和
           bzcjCxFzZhuGuanTablesId.forEach(function (value) {
               let row= $("#"+value).datagrid("getRows");
               let resultMoney = row[0].resultMoney;
               //判断不能为空、0、未定义、null以及是数字
               if (resultMoney && !isNaN(resultMoney)){
                   resultSumMoney+= Number(resultMoney);
               }
           })
           //总计划主管数据
           var totalZhuGuanTable=$("#bzcjTotalZhuGuanTable").datagrid("getRows");
           if (totalZhuGuanTable.length>0){
             let  resultMoney= totalZhuGuanTable[0].resultMoney
               if (resultMoney && !isNaN(resultMoney)){
                   resultSumMoney+= Number(resultMoney);
               }
           }
           $("#bzZhuGuanTatalMoneyInput").textbox("setValue",fomatFloat(resultSumMoney,2));
       }
   </script>
    <script src="/js/jxAssess/bzcj/bzcjZhuGuan.js"></script>
</div>